﻿@model Sharp.WebBooter.Areas.CMS.Models.SpecialReViewViewModel
@{
    Layout = null;
}


<section class="content">
    <div class="row">
        <div class="col-md-7">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">内容预览</h3>
 
                </div>
                <div class="box-body no-padding form-horizontal">
                    <div class="form-group">
                        <label class="col-md-3 control-label">栏目分类：</label>
                        <div class="col-md-9">

                        </div>
                    </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">主题：</label>
                            <div class="col-md-9">
                                @Html.Bootstrap().TextBoxFor(x => x.Title)
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">缩略图：</label>
                            <div class="col-md-9">
                                <div class="row">
                                    <div class="col-sm-6 col-md-3" draggable="true">
                                        <div class="thumbnail">
                                            <img draggable="false" src="@Model.Thumbnail" alt="">
                                            <div class="file-actions">
                                                <div class="file-footer-buttons">
                                                    <button class="btn btn-default btn-sm" type="button"> <i class="fa fa-search"></i></button>
                                                </div>
                                                <div class="clearfix"></div>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">VIU关联：</label>
                            <div class="col-md-9">
                                <fieldset style="width: 80%;">
                                    <legend>VIU关联</legend>
                                    <div class="VIUList">
                                        <ul style="max-height: 400px;" class="list-unstyled">
                                            @foreach (var item in Model.VIUs)
                                            {
                                                <li>&nbsp;<a href="#">@item.Title</a>
                                                </li>
                                            }
                                            @if (Model.VIUs.Count == 0)
                                            {
                                                <li>
                                                    没有VIU关联。
                                                </li>
                                            }
                                        </ul>
                                    </div>
                                </fieldset>


                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">封面图：</label>
                            <div class="col-md-9">
                                <div class="row">
                                    <div class="col-sm-6 col-md-3" draggable="true">
                                        <div class="thumbnail">
                                            <img draggable="false" src="@Model.CoverPictrue" alt="">
                                            <div class="file-actions">
                                                <div class="file-footer-buttons">
                                                    <button class="btn btn-default btn-sm" type="button"> <i class="fa fa-search"></i></button>
                                                </div>
                                                <div class="clearfix"></div>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">描述：</label>
                            <div class="col-md-9">
                                @Html.Bootstrap().TextareaFor(x => x.Content)
                            </div>
                        </div>
                  


                </div>
                
            </div>
        </div>
        <div class="col-md-5">
            <div class="btn-group">
                <a href="javascript:window.app.loadUI('@Url.Action("Index")');" class="btn btn-default"><i class="fa fa-backward"></i> 返回专题</a>
                <a href="javascript:window.app.loadUI('@Url.Action("Review")');" class="btn btn-default"><i class="fa fa-refresh"></i> 刷新</a>
                <a href="javascript:void(0)" onclick="$('#history').modal('show');" class="btn btn-default"><i class="fa fa-history"></i> 审核历史 <span class="badge">@Model.ApproveHistories.Count</span></a>
            </div>
            @if (Model.IsChecked)
            {
                <div class='callout callout-info'>
                    <h4>
                        <i class='fa fa-info'></i> 注意:
                    </h4>这个专题已经审核。
                </div>
            }
            @if (Model.ApproveHistories.Any() && Model.ApproveHistories.All(x => x.CheckInTime < Model.CheckInTime))
            {
                <div class='callout callout-info'>
                    <h4>
                        <i class='fa fa-info'></i> 注意:
                    </h4>这篇专题审核后有修改。
                </div>
            }
            <div class='box box-solid'>
                <div class="box-header with-border">
                    <h3 class="box-title">审核信息</h3>
                </div>
                <div class="box-body no-padding" id="reviewForm">

                    @using (Html.Bootstrap().BeginForm(c => c.Horizontal()))
                    {
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否通过</label>
                            <div class="col-sm-9">
                                <label><input type="radio" name="IsChecked" value="true" /> 通过</label>
                                <label><input type="radio" name="IsChecked" value="false" /> 不通过</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">审批意见</label>
                            <div class="col-sm-9">
                                <textarea name="Remark" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-3 col-sm-9">
                                <button type="button" onclick="SaveReview()" class="btn btn-default">确定</button>
                            </div>
                        </div>
                        <input type="hidden" name="SpecialId" value="@Model.Id" />
                    }
                </div>
            </div>


        </div>
    </div>
</section>
<div class="modal fade " aria-hidden="true" id="history">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span></button>
                <h4 class="modal-title" id="myModalLabel">审核历史</h4>
            </div>
            <div class="modal-body">
                <table class="table table-bordered table-striped" role="grid" aria-describedby="example_info" style="width: 100%;">
                    <thead>
                        <tr role="row">
                            <th class="center" rowspan="1" colspan="1" style="width: 100px;">是否通过</th>
                            <th class="left" rowspan="1" colspan="1" style="width: 100px;">审核人</th>
                            <th class="left" rowspan="1" colspan="1">审核意见</th>
                            <th class="center" rowspan="1" colspan="1" style="width: 120px;">日期</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.ApproveHistories)
                        {
                            <tr role="row" class="odd @(item.IsChecked?"":"danger")">
                                <td class="center">@(item.IsChecked ? "通过" : "未通过")</td>
                                <td class="left">@item.ApproverName</td>
                                <td class="left">@item.Remark</td>
                                <td class="center">@item.CheckInTime.Value.ToString("MM-dd HH:mm:ss")</td>
                            </tr>
                        }
                        @if (Model.ApproveHistories.Count == 0)
                        {
                            <tr role="row" class="odd">
                                <td class="left" colspan="3">无审核历史</td>
                            </tr>
                        }
                    </tbody>
                </table>

            </div>
        </div>
    </div>
</div>
<script>
    function SaveReview() {
        $.ajax({
            type: "POST",
            url: "@Url.Action("SaveReview")",
            data: $("#reviewForm form").serialize(),
            dataType: "json",
            success: function (data) {
                if (data.errors.length > 0) {
                    swal("出错啦！", data.errors, "error");
                }
                else {
                    window.app.loadUI("@Url.Action("Index")");
                }
            },
            error: function (xmlHttpRequest, textStatus, errorThrown) {
                window.app.message("服务器异常。" + textStatus);
            }
        });
    }
</script>